package com.teach.controller.certificate;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import com.teach.entity.CertificateType;
import com.teach.service.CertificateTypeService;

/**
 * <pre>
 * 
 * 创建时间:	2019年12月18日下午4:04:26
 * 当前版本: V1.0
 * 版权说明: Copyright © 1998 - 2019 cyc.top. All Rights Reserved
 *<pre>
 * @author cyc
 */
@Controller
@RequestMapping("/")
public class CertificateTypeController {
	
	@Autowired
	private CertificateTypeService TypeService; 
	
	/**
	 * 添加
	 * @param certificateType
	 */
	
	@GetMapping("/addcertificateType.do")
	@ResponseBody
	public void doCertificateInfoSelectAll(CertificateType certificateType) {
		TypeService.add(certificateType);
		
	}
	
	/**
	 * 修改
	 * @param certificateType
	 */
	
	@GetMapping("/updatecertificateType.do")
	@ResponseBody
	public void doCertificateInfoGet(CertificateType certificateType) {
		TypeService.update(certificateType);
	}
	
	/**
	 * 删除（Info_Id）
	 * @param certificateType
	 * @param infoId
	 */
	
	@GetMapping("/delectcertificateType.do")
	@ResponseBody
	public void doCertificateInfoGet1(CertificateType certificateType,Long typeId) {
		TypeService.delect(typeId);
	}
	
	/**
	 * 查询所有
	 * @param certificateType
	 * @param infoId
	 * @param model
	 * @return
	 */
	
	@GetMapping("/certificateTypeListAll.do")
	@ResponseBody
	public List<CertificateType> doGetListAll(CertificateType certificateType,Long typeId,Model model) {
		List<CertificateType> certificateTypeList =  TypeService.listAll();
		model.addAttribute("certificateInfoList", certificateTypeList);
		System.out.println(certificateTypeList);
		return certificateTypeList;
		
	}
	
	/**
	 *  根据信息编号(Type)查询
	 * @param certificateType
	 * @param TypeId
	 * @param model
	 * @return
	 */
	
	@GetMapping("/certificateInfoinfoId.do")
	@ResponseBody
	public List<CertificateType> doGetInfoId(CertificateType certificateType,Long TypeId,Model model) {
		List<CertificateType> certificateTypeId =  (List<CertificateType>) TypeService.get(TypeId);
		model.addAttribute("certificateInfoId", certificateTypeId);
		System.out.println(certificateTypeId);
		return certificateTypeId;
		
	}
	
	
	
}
